package net.wofly.cashier.order.util;

/**
 * 订单状态
 * <ul>
 * <li>订单状态分为3段两位为一段：结帐状态 + 阶段 + 操作</li>
 * <li>10XXXX表示正常下单的状态；20XXXX表示结帐后进行加菜的状态</li>
 * <li></li>
 * </ul>
 *
 * @author lign
 * @version 1.0
 * @created 17-10月-2017 21:57:08
 */
public enum OrderStatus {
    下单(101010, "下单"),
    加菜(101020, "加菜"),
    菜上齐(102010, "菜上齐"),
    己结帐(103010, "己结帐"),
    加菜未结帐(201020, "加菜未结帐"),
    加菜上齐(202010, "加菜上齐"),
    加菜己结帐(203010, "加菜己结帐"),
    交账(301010, "交账");
    
    private Integer value;
    private String name;
    
    private OrderStatus(Integer value, String name) {
        this.value = value;
        this.name = name;
    }
    
    public static boolean isValueCorrect(Integer value) {
        for (OrderStatus forEnum : values()) {
            if (value == forEnum.getValue()) {
                return true;
            }
        }
        return false;
    }
    
    public static String getName(Integer value) {
        for (OrderStatus forEnum : values()) {
            if (value.equals(forEnum.getValue())) {
                return forEnum.name;
            }
        }
        return null;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public Integer getValue() {
        return value;
    }
    
    public void setValue(Integer value) {
        this.value = value;
    }
}